import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";
import Login from "../views/Login.vue";
import Regist from "../views/Regist.vue";
//test
import Test from "../test/test.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/test",
    component: Test,
    props: true,
  },
  {
    path: "/regist",
    name: "Regist",
    component: Regist,
    meta: {
      title: "用户注册",
    },
  },
  {
    path: "/login",
    name: "Login",
    component: Login,
    meta: {
      title: "用户登录",
    },
  },
  {
    path: "/",
    name: "Home",
    component: Home,
    meta: {
      title: "首页",
    },
  },
  {
    path: "/goodslist",
    name: "Goodslist",
    component: () => import("../views/Goodslist.vue"),
    meta: {
      title: "味多美商城",
    },
    redirect: "/goodslist/cakelist",
    children: [
      {
        path: "cakelist",
        props: true,
        component: () => import("../views/Cakelist.vue"),
        meta: {
          title: "味多美商城",
        },
      },
      {
        path: "cardlist",
        props: true,
        component: () => import("../views/Cardlist.vue"),
        meta: {
          title: "味多美商城",
        },
      },
      {
        path: "joinus",
        component: () => import("../views/Joinus.vue"),
        meta: {
          title: "味多美商城",
        },
      },
    ],
  },
  {
    path: "/goodsdetail/:goods_id",
    props: true,
    name: "Goodsdetail",
    component: () => import("../views/Goodsdetail.vue"),
    meta: {
      title: "味多美商城",
    },
  },
  {
    path: "/search",
    name: "Search",
    component: () => import("../views/Search.vue"),
    meta: {
      title: "搜索",
    },
  },
  {
    path: "/cart",
    name: "Cart",
    component: () => import("../views/Cart.vue"),
    meta: {
      title: "购物车",
    },
  },
  {
    path: "/my",
    name: "My",
    component: () => import("../views/My.vue"),
    meta: {
      title: "我的",
    },
  },
  {
    path: "/userinfo",
    name: "UserInfo",
    component: () => import("../views/UserInfo.vue"),
    meta: {
      title: "个人信息",
    },
  },
  {
    path: "/address",
    name: "Address",
    component: () => import("../views/Address.vue"),
    meta: {
      title: "收货地址",
    },
  },
  {
    path: "/addsite",
    name: "AddSite",
    component: () => import("../views/AddSite.vue"),
    meta: {
      title: "新增地址",
    },
  },
  {
    path: "/order/:selected",
    name: "Order",
    props: true,
    component: () => import("../views/Order.vue"),
    meta: {
      title: "我的订单",
    },
  },
  {
    path: "/about",
    name: "About",
    component: () => import("../views/About.vue"),
    meta: {
      title: "关于我们",
    },
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
